package com.topisv.tms.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 区域
 */
@Entity
@Table(name = "pms_area")
public class Area extends IdEntity implements Serializable {
	
	private static final long serialVersionUID = 1L;
	/**
	 * 标准行政区域代码
	 * 参考:http://www.stats.gov.cn/tjbz/xzqhdm/t20120105_402777427.htm
	 */
	
	
	private Long areagroupId;
	
	private AreaGroup areaGroup;
	
	private String areaName;
	
	private String areaType;
	
	private String areaCode;
	
	private String zipCode;

	private Long parentId;
	
	private Area area;
	
	private String status;
	
	
	public Area() {
	}

	public Area(Long id) {
		this.id = id;
	}

	@Transient
	@JsonIgnore
	public Long getAreagroupId() {
		return areagroupId;
	}

	public void setAreagroupId(Long areagroupId) {
		this.areagroupId = areagroupId;
	}

	@ManyToOne
	@JoinColumn(name = "areagroup_id")
	public AreaGroup getAreaGroup() {
		return areaGroup;
	}

	public void setAreaGroup(AreaGroup areaGroup) {
		this.areaGroup = areaGroup;
	}

	@Column(name="area_name")
	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}
	@Column(name="area_type")
	public String getAreaType() {
		return areaType;
	}

	public void setAreaType(String areaType) {
		this.areaType = areaType;
	}
	@Column(name="area_code")
	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}
	@Column(name="zip_code")
	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	
	@Transient
	@JsonIgnore
	public Long getParentId() {
		return parentId;
	}

	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}

	@ManyToOne
	@JoinColumn(name = "parent_id")
	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}